package com.elong.businesstravel.protocol.city;

import java.util.ArrayList;
import java.util.List;

import org.apache.http.Header;
import org.json.JSONArray;
import org.json.JSONObject;

import com.elong.businesstravel.entitys.Chains;
import com.elong.businesstravel.protocol.baseresponse.BaseELongJsonHttpResponse;

public class GetCityChainResponse extends BaseELongJsonHttpResponse {

	public List<Chains> chains = new ArrayList<Chains>();
	
	@Override
	public void onSuccess(int statusCode, Header[] headers,
			JSONObject mainJsonObject) throws Throwable {
		JSONObject  responseJsonObject = mainJsonObject.getJSONObject("response");
		JSONArray chainsJsonArray = responseJsonObject.getJSONArray("chains");
		for (int i = 0; i < chainsJsonArray.length(); i++) {
			Chains itemChains = new Chains();
			JSONObject itemJsonObject = chainsJsonArray.getJSONObject(i);
			itemChains.shortname = itemJsonObject.optString("shortname", "");
			itemChains.brandid = itemJsonObject.optString("brandid", "");
			itemChains.precount = itemJsonObject.optString("precount", "");
			itemChains.hotelcount = itemJsonObject.optString("hotelcount", "");
			itemChains.letters = itemJsonObject.optString("letters", "");
			itemChains.cityid = itemJsonObject.optString("cityid", "");
			chains.add(itemChains);
		}
	}

}
